<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="cn.edu.nju.ws.sview.Config,cn.edu.nju.ws.sview.views.Group,java.util.Enumeration,java.util.HashSet,java.util.ArrayList,cn.edu.nju.ws.sview.views.User" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SView编制组设置</title>
<link rel="icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="/sview/css/bootstrap_button.min.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/layout.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/lang_set.css" />
<link rel="stylesheet" type="text/css" href="/sview/css/easyui.css" />
<script type="text/javascript" src="/sview/script/jquery.js"></script>
<script type="text/javascript" src="/sview/script/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/sview/script/global.js"></script>
<script type="text/javascript" src="/sview/script/groupSet.js"></script>
</head>
<body>
<%
	String lang = request.getParameter("lang");
	if(lang!=null &&lang.equals("en")){
		request.getRequestDispatcher("groupset.jsp").forward(request,response);
		return;
	}else if(lang==null){
		lang="zh";
	}
	String from = request.getParameter("f");
	String user = (String)session.getAttribute("user"); 
	if(user==null){
		String location = "../views/index.jsp";
		if(lang.equals("zh"))
			location = location+"?lang="+lang;
		response.sendRedirect(location);
		return;
	}
	String groupName = (String)session.getAttribute("groupName");   
%>
<div class="header_bar" >
  <div class="bar-container">
    <div class="nav">
     <ol>
       <li><span class="lc"><a href='/sview/views/index.jsp?lang=zh'>实体</a></span></li>
       <li><span class="lc"><a href='/sview/relations/index.jsp?lang=zh'>数据集</a></span></li>
     </ol>
    </div>
    <div class="setting">
      <ol>
        <li><span class="lc"><span class="uinfo">
        <%=user %>
        </span></span></li>
        <li><span class="usplitBox"><span class="usplit"></span></span></li>
        <li><span class="lc"><a id="set-option" href="javascript:void(0)"><span class="set_options"></span></a></span></li>
      </ol>
    </div>
  </div>
  <div class="dmenu" id="dmenu">
    <ol>
     <li><a href="/sview/preference?lang=zh">语言设置</a></li>
    </ol>
  </div>
</div>
<div class="container">
   <div class="top">
      <div class="mspacing"></div>
     <div class="operation">编辑组设置</div>
     <div class="mspacing"></div>
   </div>
   <div class="mspacingLittle"></div>
   <div class="main">
	<div class="leftPanel">
	 <ol class='leftnav'>
        <li><a class="nav-item d" href="javascript:void(0)	" onclick="return false">Editing Group</a></li>
     </ol>
	</div>
	<div class="rightPanel">
	  <div class="group-set">
	     <div class="option">
	     <%
	     if((new User(user)).getGroups().size()>0){ %>
	     <div class="hint">你想选择哪个编辑组从事编辑工作?</div>
	      <div class="box">
	     <%
	        int groupID = 0;
	        if(groupName!=null){
	        	groupID = Group.getGroupIdByName(groupName);
	        }
	        User muser = new User(user);
	         HashSet<Integer>  groupIDs = muser.getGroups();
	         if(groupID>0){
	        	 groupIDs.remove(new Integer(groupID));
	         }
	         ArrayList<Integer> groupList = new ArrayList<Integer>();
	         if(groupID>0){
	        	 groupList.add(groupID);
	         }
	         groupList.addAll(groupIDs);
	         for(int i=0;i<groupList.size();i++){
	     %>
	          <div class="group_option">
	     <%
	        	 int gid = groupList.get(i);
	        	 String gname = Group.getGroupNameById(gid);
	        	 if(i>0){
	     %>
                <input type="radio" name="gselect" value="<%=gid%>">
             <%  }else{%>
                 <input type="radio" name="gselect" value="<%=gid%>" checked>
             <% 
                 }
	      %>
	        <span><%=gname%></span> </div>
	      <%
	         }
	         %>	      
	     </div>
	     <%}else{ %>
	        <div class="hint">你尚未加入任何编辑组。你可以在”我的编辑组“中创建和管理组。现在去”我的编辑组“中吗？</div>
	     <%} %>
	     </div>
	   <!-- <div class='hint2'><input type="checkbox" id="svdefault" checked />下次登陆默认使用这个编辑组。</div> -->  
         <div class="mspacingLittle dis"></div>
	     <div class="form-button">
	       <div id ="groupbuttons" class="formbuttons">
	        <% if((new User(user)).getGroups().size()>0){ %>
	        <input type="button" value="保存" class="sbutton btn btn-primary fb">
	        <%}else{ %>
	         <input type="button" value="好的" class="sbutton btn btn-primary fb">
	        <%} %>
	        <input type="button" value="取消" class="cbutton btn fb">
	       </div>
	     </div>
	  </div>
	</div>
	</div>
</div>
<input type="hidden" id="display-lang" name="display-lang" value="zh"/>
<input type="hidden" id="groupName"  value="<%=groupName%>"/>
<%if(from!=null){ %>
  <input type="hidden" id="f"  value=<%=from%> /> 
<%} %>
<jsp:include page="/vfooter_zh.jsp"></jsp:include>
</body>
</html>